home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / gmai13.zip / GMAIL.XWS < prev    next >
Text File  |  1991-10-12  |  11KB  |  355 lines

  1. /* 
  2. gMail version 1.3 - G. Gallo
  3. Crosstalk for Windows MarkMail Qmail Automator version 1.3
  4. (c) Guy Gallo, 1991
  5. If you use this script, please register by sending $15.00 to:
  6. 219 East 69th Street
  7. New York, NY 10021
  8.  
  9. You may *not* distribute modified versions of this script, either for a
  10. fee, or for no fee.  You may freely distribute the ZIP, as long as it
  11. includes all of the files as originally distributed by me.  Any distribution
  12. via other mediums must be approved by me.
  13. */
  14.  
  15. STRING Main$, Conf$, cConf$, qMail$, mMail$, qCfig$, Null$, Temp$, ConfigureCommand$
  16. STRING RepName$, QwkName$, DirRep$, DirQwk$, SaveQwk$, DoorCmd$, Reader$, DoCmd$, CurLine$
  17. STRING Board$, Phone$, Ver$, TempQwk$, cMain$
  18.  
  19. INTEGER MailReplies, MailOnly, RepliesOnly, LogOut, LoadReader, xExec, InConfig
  20. INTEGER ConfigureMail, Icon, Flag, Success, Ask, Auto, NoMail, Reset, InMail, x
  21. Ver$ = "1.3"
  22. --Contants
  23. Board$ = "INV-FAC" 
  24. Main$ = "Board Command?"
  25. cMain$ = "Your Command"
  26. Conf$ = "rence Command?"
  27. cConf$ = "Conference - You"
  28. qMail$= "Qmail Command?"
  29. qCfig$= "igure Command?"
  30. mMail$= "kMail Command?"
  31. Null$ = ""
  32. Temp$ = Null$
  33. ConfigureCommand$ is "C"
  34. Reader$ is "WINQWK.EXE"
  35. DoCmd$ is "n s u"
  36. DoorCmd$ is "Qmail4"
  37. if NetId <> Null$ Then DoorCmd$ = NetID
  38. Success = True
  39. InMail = False
  40. --Get defaults from script argument
  41. Temp$ is Arg(0)
  42. Temp$ is Upcase(Temp$)
  43.  
  44. If Temp$ is Null$ or Temp$ is "/ASK" Then Ask is True : NoMail is True : Goto Start
  45.  
  46. Flag = 0
  47. if Instr(Temp$, "/MR") Then MailReplies = True : Flag = Flag + 1
  48. if Instr(Temp$, "/MO") and Not MailReplies Then MailOnly = True : Flag = Flag+ 1
  49. if Instr(Temp$, "/RO") and Not MailReplies and Not MailOnly Then RepliesOnly = True : Flag = Flag + 1
  50. if Instr(Temp$, "/NM") and Not MailReplies and Not MailOnly and Not RepliesOnly Then NoMail  = True : Flag = Flag +1
  51. if Flag = 0 Then NoMail = True 
  52. Flag = 0
  53. if Instr(Temp$, "/ASK") Then Ask = True : Flag = Flag + 1
  54. if Instr(Temp$, "/AUTO") Then Auto = True : Flag = Flag + 1
  55. if Flag = 0 and Not NoMail Then Ask is True
  56. Flag = 0
  57. if Instr(Temp$, "/O") Then LogOut = True : Flag = Flag + 1
  58. if Instr(Temp$, "/DO") Then xExec = True : Flag = Flag + 1
  59. if Flag = 0 Then Logout = False
  60. if Instr(Temp$, "/B:") Then Board$ is Slice(Temp$, 1,"/", Instr(Temp$, "/B:")+3)
  61. if Instr(Temp$, "/DR:") Then DoorCmd$ is Slice(Temp$, 1,"/", Instr(Temp$, "/DR:")+4)
  62. if Instr(Temp$, "/D:") Then DoCmd$ is Slice(Temp$, 1,"/", Instr(Temp$, "/D:")+3)
  63. If Instr(Temp$, "/LR") Then LoadReader = True
  64. if Instr(Temp$, "/R:") Then Reader$ is Slice(Temp$, 1,"/", Instr(Temp$, "/R:")+3)
  65. If Instr(Temp$, "/I") Then Icon = True
  66. If Instr(Temp$, "/CO") Then ConfigureMail = True
  67. If Instr(Temp$, "/C:") Then ConfigureCommand$ is Slice(Temp$, 1,"/", Instr(Temp$, "/C:")+3)
  68.  
  69. LABEL Start
  70. Message "[gMail] Starting..."
  71. Temp$ = Null$
  72. If Not Online then 
  73.         {
  74.         TRAP ON
  75.         If Ask Then Gosub ShowDialog
  76.         Load Board$
  77.         Phone$ = Number
  78.         Temp$ is Script
  79.         Script is Null$
  80.         Dial Phone$
  81.         TRAP OFF
  82.         If Not Online Then Script is Temp$ : Save : Halt
  83.         Reset is True 
  84.         }            
  85. Wait Quiet 8 Ticks
  86. TRAP ON
  87. Board$ is Name 
  88. Reader$ = Reader$ + " " + Board$+".QWK"
  89.  
  90. if Online Then :...
  91.         CurLine$ is WinString(yPos,xPos-21,20)
  92. TRAP OFF
  93. If Error Then {
  94.         if Not InMail Then Reply 
  95.         Message "[gMail] Starting...Error..."
  96.         wait quiet 2 ticks
  97.         Goto Start
  98.         }
  99. If Icon Then Minimize
  100. Message "[gMail] Logging onto "+ Board$
  101. If Instr(CurLine$,"first name?") Then Reply : Goto WatchLoop
  102. If Instr(CurLine$,"cs (Enter)=no?")  OR Instr(UpCase(CurLine$),"GRAPHICS") Then Reply "N Q" : Goto WatchLoop
  103. If Instr(CurLine$,"er)=no change?") Then Reply : Goto WatchLoop
  104. If Instr(Curline$,Main$) or Instr(CurLine$,Conf$) or Instr(CurLine$,cMain$) or Instr(CurLine$,cConf$) then Goto DoneLogon
  105. If InStr(Curline$,mMail$) or Instr(CurLine$, qMail$) then
  106.         {
  107.         InMail is True
  108.         If Ask then Gosub ShowDialog
  109.         Goto AtMailPrompt
  110.         }
  111.  
  112. LABEL WatchLoop
  113. Message "[gMail] Logon prompts..."
  114. while online
  115. watch for
  116.       'first name?'     : wait 5 ticks  : reply UserID
  117.       'last name?'      : wait 5 ticks  : reply 
  118.       'first and last'  : wait 5 ticks  : reply UserID
  119.       'correct? ('      : Reply "y"
  120.       'dots).?',
  121.       'echo'            : wait 4 ticks  : reply Password
  122.       'a new user?'     : wait 4 ticks  : end
  123.       'cs (Enter)=no?',
  124.       'LOR & GRAPHICS'  : wait 4 ticks  : Reply "N Q" 
  125.       '=no?',
  126.       'tinue?',
  127.       'tinue:',
  128.       'stop?',
  129.       '(NS)?',
  130.       'use (Enter)=no change?',
  131.       'More?'           : wait 4 ticks  : reply
  132.       'Check your mail' : reply "N"      
  133.       '=yes?'           : wait 4 ticks  : reply "N"
  134.       Main$,
  135.       cMain$,
  136.       Conf$,
  137.       cConf$            : Goto DoneLogon
  138.       Key 27            : Halt
  139.      endwatch
  140.  wend
  141.  
  142. LABEL DoneLogon
  143. If Reset and Online then Script is Temp$ : Save
  144. If Ask Then Gosub ShowDialog
  145. If NoMail Then  
  146.         {
  147.         Wait Quiet 5 Ticks 
  148.         if xExec Then 
  149.                 {
  150.                 Reply DoCmd$ 
  151.                 Wait Quiet 6 Ticks
  152.                 Gosub ReturnToPcBoard
  153.                 }
  154.         If Logout Then 
  155.                 {
  156.                 reply "g"
  157.                 Message "[gMail] Logging off."
  158.                 Wait quiet 5 ticks
  159.                 If LoadReader then Run Reader$
  160.                 Halt
  161.                 }
  162.                 else 
  163.                 {
  164.                 Alarm
  165.                 Message "[gMail] Done..."
  166.                 Halt
  167.                 }
  168.          }       
  169. Reply DoorCmd$
  170. WAIT 5 TICKS
  171.  
  172. --Second Watch loop
  173. LABEL LOOP
  174. While OnLine
  175.         Watch For
  176.         mMail$,
  177.         '<COMMAND>',
  178.         qMail$          : Goto AtMailPrompt
  179.         Key 27          : Halt
  180.   endwatch
  181. Wend
  182.  
  183. LABEL ShowDialog
  184. Message "[gMail] Set options..."
  185.    DIALOGBOX 25, 15, 235, 125
  186.       LTEXT 3, 6, 93, 8, "gMail "+ Ver$ + " - calling: /B:"
  187.       GROUPBOX 4, 18, 94, 82, "Mail Options"
  188.       RADIOBUTTON 6, 28, 86, 10, "&Mail and Replies /MR", MailReplies, tabstop group
  189.       RADIOBUTTON 6, 38, 62, 10, "M&ail Only /MO", MailOnly
  190.       RADIOBUTTON 6, 48, 64, 10, "&Replies only /RO", RepliesOnly
  191.       RADIOBUTTON 6, 58, 87, 10, "&Configure mail door /CO", ConfigureMail
  192.       RADIOBUTTON 6, 85, 90, 10, "&No Mail processing /NM", NoMail
  193.       EDITTEXT 28, 72, 62, 12, ConfigureCommand$, CONFIGURECOMMAND$
  194.       LTEXT 15, 75, 11, 8, "/C:"
  195.       LTEXT 3, 106, 100, 8, "Open mail door command /DR:"
  196.       EDITTEXT 110, 103, 45, 12, DoorCmd$, DOORCMD$
  197.       EDITTEXT 86, 4, 48, 12, Board$, BOARD$
  198.       CHECKBOX 148, 5, 81, 10, "&Iconize after logon /I", Icon
  199.       GROUPBOX 102, 18, 126, 82, "Post Mail Options"
  200.       CHECKBOX 115, 28, 100, 10, "&Do Main Board command /DO", Xexec, tabstop
  201.       LTEXT 105, 45, 10, 8, "/D:"
  202.       EDITTEXT 115, 42, 110, 12, DoCmd$, DOCMD$, tabstop
  203.       CHECKBOX 115, 58, 74, 10, "&Launch Reader /LR", LoadREader, tabstop
  204.       LTEXT 105, 70, 11, 8, "/R:"
  205.       EDITTEXT 115, 68, 110, 12, Reader$, READER$, tabstop
  206.       CHECKBOX 115, 87, 93, 10, "Log &off when complete /O", LogOut, tabstop
  207.       DEFPUSHBUTTON 166, 106, 28, 11, "OK" 
  208.       PushButton 202, 106, 28, 11, "Cancel", Cancel
  209. ENDDIALOG
  210. Message "[gMail] Working..."
  211. Auto is True : Ask is False
  212. If OnLine and Icon Then Minimize
  213. If Choice = 2 Then Halt
  214. RETURN
  215.  
  216. LABEL AtMailPrompt
  217. InMail is True
  218. InConfig is False
  219. If ConfigureMail Then 
  220.         {
  221.         Reply ConfigureCommand$ 
  222.         Message "[gMail] Select options; Q for gMail menu..."
  223.         Wait quiet 5 ticks
  224.         InConfig is True
  225.         Gosub Cleanup
  226.         Auto is False 
  227.         Ask is true 
  228.         NoMail is true
  229.         ConfigureMail is False
  230.         InConfig is False
  231.         Goto Start
  232.         }
  233. Message "[gMail] At Mail prompt, doing mail..."
  234. InMail is True
  235. RepName$ is NAME+".REP"
  236. QwkName$ is NAME+".QWK"
  237. TmpQwk$ is DirFil+"\"+name+".$$$"
  238. DirRep$ is DirFil+"\"+RepName$
  239. DirQwk$ is DirFil+"\"+QwkName$
  240. SaveQwk$ is DirFil+"\"+inject(QwkName$,"1",1)
  241. if RepliesOnly Then Gosub SendFiles
  242. if MailReplies Then Gosub SendFiles : Gosub GetPacket
  243. if MailOnly  Then Gosub GetPacket
  244. If xExec Then 
  245.         {
  246.         Message "[gMail] Executing ExecCommand."
  247.         GoSub ReturnToPCBoard 
  248.         Reply DoCmd$
  249.         Wait Quiet 6 Ticks
  250.         GoSub ReturnToPCBoard                
  251.         }
  252. Trap On
  253. If LogOut and InMail Then GoSub CleanUp : Wait 10 Ticks: Reply "G"
  254. If LogOut Then Wait 5 ticks : Reply "G"
  255. Alarm
  256. If LoadReader Then Wait 5 Ticks : Run Reader$
  257. Trap Off
  258. END
  259.  
  260. LABEL GetPacket
  261. Reply "D"
  262. While OnLine
  263. Watch 10 for
  264.         '[Y]es, [N]o, [G]oodbye When Done?',
  265.         '<DLASK>',
  266.         '(Y/N)?'         :  Reply "Y": GoSub DoFiles    : Goto GPOut
  267.         'no messages',
  268.         '<NO TRANSFER>'  :  Message "No Transfer"       : Goto GPOut
  269.         KEY 27           :  Message "Transfer aborted." : Goto GPOut
  270. endwatch
  271. Wend
  272. LABEL GPOut
  273. Return
  274.  
  275. LABEL DoFiles
  276.         if Exists(TmpQwk$) then Delete TmpQwk$
  277.         If Exists(SaveQwk$) then Rename SaveQwk$,TmpQwk$
  278.         If Exists(DirQwk$) then Rename DirQwk$,SaveQwk$ 
  279.         Message "[gMail] Renaming old QWK..."
  280.         Trap ON
  281.         Watch for
  282.                 '(Ctrl-X) Aborts Transfer' : Receive QwkName$ : Gosub CheckSuccess
  283.                 '<DOWNLOAD>'               : Receive QwkName$ : Gosub CheckSuccess
  284.         endwatch
  285.         If Success Then
  286.         {
  287.         If Exists(TmpQwk$) Then Delete TmpQwk$
  288.         Message "[gMail] Transfer complete."
  289.         }
  290.         else
  291.         {
  292.         Delete DirQwk$
  293.         if Exists(SaveQwk$) then Rename SaveQwk$, DirQwk$
  294.         if Exists(TmpQwk$) then Rename TmpQwk$, SaveQwk$
  295.         Message "[gMail] Transfer failed!"
  296.         }
  297.         TRAP OFF
  298. Return
  299.  
  300. LABEL SendFiles
  301. If exists(DirRep$) then
  302.    {
  303.      Reply "U" 
  304.      Wait 5 ticks 
  305.      TRAP ON
  306.      Send RepName$ 
  307.      GoSub CheckSuccess
  308.      if Success Then Delete DirRep$ : Message "[gMail] Deleting reply file..." :...
  309.              Else Message "Keeping REP file"
  310.      TRAP OFF
  311.    }
  312. Return
  313.  
  314. LABEL CleanUp
  315. While OnLine
  316.   Watch For
  317.         mMail$,
  318.         '<COMMAND>',
  319.         qMail$       :  Message "[gMail] Done with mail..." : Goto CUOut
  320.         key 27       :  Halt
  321.   endwatch
  322. --  If TimeOut And InConfig = 0 then reply 
  323. Wend  
  324. LABEL CUOut
  325. Return
  326.  
  327.   
  328. LABEL ReturnToPCBoard
  329.   Message "[gMail] Returning to PCBoard..."
  330.   x = 0
  331.   if InMail Then Reply "q" : InMail is False
  332.   While OnLine
  333.   Watch 14 For
  334.         Main$,
  335.         Conf$,
  336.         cMain$    : Message "[gMail] Back at PCBoard." : Goto RTPOut
  337.         Key 27    : Halt
  338.        'password' : Reply PassWord
  339.   EndWatch    
  340.   If TimeOut Then Reply      : x = x + 1
  341.   if x > 10 Then Bye : Halt
  342.   Wend    
  343. LABEL RTPOut
  344. Return  
  345.  
  346. LABEL CheckSuccess
  347. Success is True
  348. If Error Then...
  349.         If ErrClass = 45 or ErrClass = 20 Then Success = False
  350. Return
  351.  
  352. LABEL DoRec
  353. If Protocol <> "ZMODEM" Then Receive QwkName$
  354. Return
  355.